//===============================================================================
// Microsoft patterns & practices
// Web Client Software Factory
//-------------------------------------------------------------------------------
// Copyright (C) Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//-------------------------------------------------------------------------------
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using WCSFContrib.PageFlow.Utils;

namespace WCSFContrib.PageFlow.Xml.Configuration
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface")]
    public class NodeConfigurationElementCollection : ConfigurationElementCollection
    {
        public NodeConfigurationElementCollection()
        {
        }

        [ConfigurationProperty("view", IsRequired = true)]
        public string View
        {
            get { return (string)base["view"]; }
            set { base["view"] = value; }
        }

        protected override bool ThrowOnDuplicate
        {
            get { return true; }
        }

        public void Add(NavigateToConfigurationElement navigateNode)
        {
            BaseAdd(navigateNode);
        }

        public bool Contains(string navigateNode)
        {
            return base.BaseGet(navigateNode) != null;
        }

        public override ConfigurationElementCollectionType CollectionType
        {
            get { return ConfigurationElementCollectionType.BasicMap; }
        }

        protected override string ElementName
        {
            get { return "navigateTo"; }
        }

        protected override ConfigurationElement CreateNewElement()
        {
            return new NavigateToConfigurationElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((NavigateToConfigurationElement)element).NavigateValue;
        }

        public NavigateToConfigurationElement this[int index]
        {
            get { return (NavigateToConfigurationElement)base.BaseGet(index); }
        }
    }
}
